<h2 class="contentTitle">编辑推广信息</h2>
<form action="<?php echo SITE_URL . 'index.php?c='.$controller.'&a=ajaxEdit';?>" method="post" class="pageForm required-validate" onsubmit="return validateCallback(this, dialogAjaxDone)">
    <div class="pageContent">
        <div layouth="97" class="pageFormContent nowrap" style="height: 376px; overflow: auto;">
            <dl>
                <dt>推广名称：</dt>
                <dd style="width: 400px">
                    <input type="text" name="title" size="30" class="required textInput valid" value="<?php echo $info['title']; ?>">
                    <input type="hidden" name="ad_id"  value="<?php echo $info['ad_id']; ?>">
                    <input type="hidden" name="sort"  value="<?php echo $info['sort']; ?>">
                    <span class="inputInfo">填写新闻流名</span>
                </dd>
            </dl>
            <dl>
                <dt>推广简介：</dt>
                <dd style="width: 400px">
                    <textarea rows="2" cols="47" name="summary" id="summary" class="textInput">
                        <?php echo $info['summary']; ?>
                    </textarea>
                    <span class="inputInfo">填写推广简介</span>
                </dd>
            </dl>
            <dl>
                <dt>链接地址：</dt>
                <dd style="width: 400px">
                    <input type="text" name="link" size="50" class="required textInput valid" value="<?php echo $info['link']; ?>">
                    <span class="inputInfo">填写链接地址</span>
                </dd>
            </dl>
            <dl>
                <dt>推广类型：</dt>
                <dd style="width: 400px">
                    <select class="combox" name="ad_type_id">
                        <?php
                        foreach($ad_type as $k=>$v){
                            ?>
                            <option value="<?php echo $k; ?>" <?php echo $info['ad_type_id'] == $k ? 'selected="true"' : ''; ?>><?php echo $v; ?></option>
                        <?php
                        }
                        ?>
                    </select>
                    <span class="inputInfo">请选择来源</span>
                </dd>
            </dl>
            <dl>
                <dt>显示状态：</dt>
                <dd style="width: 400px">
                    <select class="combox" name="status">
                        <option value="1" <?php echo $info['status'] == $k ? 'selected="true"' : ''; ?>>显示</option>
                        <option value="2" <?php echo $info['status'] == $k ? 'selected="true"' : ''; ?>>隐藏</option>
                    </select>
                    <span class="inputInfo">显示状态</span>
                </dd>
            </dl>
            <dl>
                <dt>推广时间：</dt>
                <dd style="width: 400px">
                    <input type="text" datefmt="yyyy-MM-dd HH:mm:ss" readonly="true" name="start_time" class="date textInput readonly" value="<?php echo $info['start_time']; ?>">
                    <input style="margin-left: 15px" type="text" datefmt="yyyy-MM-dd HH:mm:ss" readonly="true" name="end_time" class="date textInput readonly focus" value="<?php echo $info['end_time']; ?>">
                    <span style="margin-left: 15px" class="inputInfo">显示推广时间段</span>
                </dd>
            </dl>
            <dl>
                <dt>推广图片：</dt>
                <dd style="width: 400px">
                    <input id="file_upload" type="file" name="picture"/>
                    <span class="inputInfo">推广图片，可为空</span>
                    <img width="320px" height="200px" id= "curr_picture" src="<?php echo $info['picture'] ? $info['picture'] : '../Upload/default/320x200.jpg'; ?>" style="border: 1px solid #000000">
                    <input type="hidden" name="picture" value="<?php echo $info['picture']; ?>">
                </dd>
            </dl>
            <dl>
                <dt>推广备注：</dt>
                <dd style="width: 400px">
                    <textarea rows="2" cols="47" name="note" id="note" class="textInput">
                        <?php echo $info['note']; ?>
                    </textarea>
                    <span class="inputInfo">填写推广备注</span>
                </dd>
            </dl>
        </div>
        <div class="formBar">
            <ul>
                <li><div class="buttonActive"><div class="buttonContent"><button type="submit">确认</button></div></div></li>
                <li><div class="button"><div class="buttonContent"><button class="close" type="button">关闭</button></div></div></li>
            </ul>
        </div>
    </div>
</form>
<script type="text/javascript">
    //动态加载上传插件
    <?php $timestamp = time();?>
    $(function() {
        $('#file_upload').uploadify({
            'onInit': function(){},
            'formData'     : {
                'type' : 'ad',
                'timestamp' : '<?php echo $timestamp;?>',
                'token'     : '<?php echo md5(MD5_CODE . $timestamp);?>'
            },
            'simUploadLimit':1,
            'swf'      : '<?php echo DWZ_URL; ?>uploadify/scripts/uploadify.swf',
            'uploader' : '<?php echo SITE_URL . 'index.php?c='.$controller.'&a=adPictureUpload';?>',
            'buttonText' : '上传图片',
            'fileSizeLimit':'2018KB',
            'fileTypeDesc':'*.jpg;*.jpeg;*.gif;*.png;',
            'fileTypeExts':'*.jpg;*.jpeg;*.gif;*.png;',
            'auto':true,
            'multi':false,
            'onUploadError' : function(file,errorCode,errorMsg,errorString,swfuploadifyQueue){
                //alert(errorMsg);//上传文件出错是触发（每个出错文件触发一次）
                alertMsg.info(errorMsg);
            },
            'onUploadSuccess':function(file,data,response){

                var data_str = data.replace("\n\n","");
                var error_str = data_str.substring(0,5);

                if(error_str == "error"){
                    alertMsg.error('上传图片异常，请联系管理员检查！');
                }else{
                    $('#curr_picture').attr('src',data_str+'?'+Math.random()).attr('original',data_str);
                    $('input[name=picture]').val(data_str);
                }
            },
            'onSelect': function (event, queueID, fileObj)
            {
                $("#file_upload").uploadify('settings','formData',{curr_picture:$('input[name=picture]').val()})
            }
        });
    });
</script>